package pct.manage;

import java.util.Map;

import org.apache.struts2.interceptor.SessionAware;

import pct.entity.User;

import com.opensymphony.xwork2.ActionSupport;

/*
 * this class helps redirect to suitable target JSP 
 */
@SuppressWarnings("serial")
public class RedirectResult extends ActionSupport implements SessionAware{
	private int redirectType = 0;
	private Map<String, Object> session;
	public String execute() {
		switch(redirectType){
		case 1:
			return "register_page";
		case 2:
			return "findpassword_page";
		case 3:
			StatusManager sm = new StatusManager();
			User visitor = new User();
			visitor.setUserType(0);
			visitor.setUsername("visitor");
			sm.setCurrentUser(visitor);
			session.put("status", sm);
			return "visitor_page";
		case 4:
			return "newTopic";
		case 5:
			return "manageAccount";
		case 6:
			return "applyNewGroup";
		case 7:
			return "searchDisease";
		case 8:
			return "systemMessage";
		case 9:
			return "exportSheet";
		case 10:
			return "homePage";
		case 11:
			return "help";
		default:
			return INPUT;
		}
	}
	
	public int getRedirectType() {
		return redirectType;
	}

	public void setRedirectType(int redirectType) {
		this.redirectType = redirectType;
	}

	@Override
	public void setSession(Map<String, Object> session) {
		this.session = session;
	}
}
